package com.popcorn.rmsystem.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.popcorn.action.Action;
import com.popcorn.action.ActionForward;
import com.popcorn.rmsystem.dao.RMSystemDAO;

public class ReservationSelectAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		RMSystemDAO rmsDAO=new RMSystemDAO();
		List list=new ArrayList();
		
		String select = request.getParameter("select");
		System.out.println(select);
		if(select.equals("1")){
			String TEAM_NAME = request.getParameter("TEAM_NAME");
			System.out.println(TEAM_NAME);
			list =rmsDAO.modelSelect_TeamName(TEAM_NAME);
		}else if(select.equals("2")){
			String rTRANDATE = request.getParameter("TRANDATE");
			String [] TRANDATE = rTRANDATE.split("-");
			System.out.println(rTRANDATE);
			list =rmsDAO.modelSelect_Date(TRANDATE[0]+TRANDATE[1]+TRANDATE[2]);
		}else if(select.equals("3")){
			String rTRANDATE = request.getParameter("TRANDATE2");
			String [] TRANDATE = rTRANDATE.split("-");
			int STARTTIME =Integer.valueOf(request.getParameter("STARTTIME"));
			int ENDTIME = Integer.valueOf(request.getParameter("ENDTIME"));
			list =rmsDAO.modelSelect_Date_Time(TRANDATE[0]+TRANDATE[1]+TRANDATE[2], STARTTIME, ENDTIME);
		}
		
		request.setAttribute("boardlist", list);
		
		ActionForward forward= new ActionForward();
	   	forward.setRedirect(false);
   		forward.setPath("RMSView.jsp");
   		return forward;
	}

}
